package com.andy.buyu.server.action;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import com.andy.buyu.server.game.FishGame;
import com.andy.buyu.server.game.GameUser;
import com.andy.buyu.server.socket.GmAction;
import com.andy.buyu.server.socket.MySocketSession;
import com.andy.buyu.server.socket.codec.DataWrap;
import com.andy.buyu.server.utils.CommonUtils;
import com.google.common.collect.Lists;

/**
 * 捕多条鱼
 * @author cuiwm
 *
 */
@Component(GmAction.ACTION_PREFIX+GmAction.ACTION_207)
public class Action207 implements IReqAction{

	private static Logger logger = LoggerFactory.getLogger(Action207.class);
	
	@Override
	public void doAction(MySocketSession session, DataWrap data) {
		GameUser user = session.getUser();
		// 12-电磁波，13-核弹，21-100像素爆炸，22-闪电链
		int bullet = data.getByte();
		int len = data.getInt();
		if(logger.isInfoEnabled()){
			logger.info("207:{}-{}-{}", user.getId(),bullet,len);
		}
		FishGame game = user.getGame();
		if(game == null) return;
		
		List<Integer> scripts = Lists.newArrayList();
		for(int i=0;i<len;i++){
			scripts.add(data.getInt());
		}
		if(!user.catchFish(bullet,0)) return ;
		
		CommonUtils.catchMultFish(user, bullet, scripts,0);
		
	}

	


	
	
	
}
